home *** CD-ROM | disk | FTP | other *** search
/ Megahits 3 / Megahits 3 (1994)(GTI - Rhein-Main-Soft)(DE)[!].iso / module / utilities / delitracker130 / rexx / dt_sort.rexx < prev    next >
OS/2 REXX Batch file  |  1994-10-14  |  3KB  |  128 lines

  1. /*
  2.  * dt_sort.rexx
  3.  *  Version 0.5
  4.  *  07-Sep-92
  5.  *  © Delirium Softdesign
  6.  *
  7.  * An ARexx script for sorting large module directories
  8.  *
  9.  * Usage: dt_sort.rexx <dir>
  10.  *
  11.  */
  12.  
  13.  
  14. /* standard setup */
  15. options results
  16. options failat 20
  17.  
  18. /* get arguments */
  19. parse arg directory .
  20.  
  21. if directory == '' then do
  22.   say 'you must specify a directory'
  23.   exit 10
  24. end
  25.  
  26. if right(directory,1) ~== ':' then do
  27.   directory = directory||'/'
  28.   if index(directory,':') == '0' then do
  29.     directory = pragma('D')||directory
  30.   end
  31. end
  32.  
  33. /* test, if the directory is vaild */
  34. if exists(directory) == '0' then do
  35.   say 'invalid directory'
  36.   exit 10
  37. end
  38.  
  39. /* test, if DeliTracker is running */
  40. if show('P','rexx_DT') == '0' then do
  41.   say 'DeliTracker is not running'
  42.   exit 10
  43. end
  44.  
  45. /* add the functions of the 'rexxsupport.library' */
  46. if addlib('rexxsupport.library',0,-30,0) == '0' then do
  47.   if show('L','rexxsupport.library') == '0' then do
  48.     say 'couldn''t open rexxsupport.library'
  49.     exit 10
  50.   end
  51. end
  52.  
  53. /* get the contents of the module directory */
  54. modlist = showdir(directory,'F',':')||':'
  55.  
  56. say 'sorting modules'
  57.  
  58. address 'rexx_DT'
  59.  
  60. /* store quickstart state */
  61. status G qst
  62. quickstart = result
  63.  
  64. /* do not play the modules after loading */
  65. quick no
  66.  
  67. /* eject the old module */
  68. eject
  69.  
  70. /* process the module directory */
  71. do until (modlist == '')
  72.  
  73.   filename = left(modlist,index(modlist,':')-1)
  74.   modlist = delstr(modlist,1,index(modlist,':'))
  75.  
  76.   if filename ~== '' then do
  77.  
  78.     playmod '"'directory||filename'"'
  79.  
  80.     status M pnr
  81.     playernum = result
  82.  
  83.     if playernum == '0' then do
  84.       say 'could not identify "'||filename'"'
  85.     end
  86.     else do
  87.  
  88.       status P playernum nam
  89.       playername = result
  90.  
  91.       /* create a new directory if necessary */
  92.       if exists(directory||playername) == '0' then do
  93.         say 'module directory "'||playername||'" did not exist. It was created.'
  94.         CALL makedir(directory||playername)
  95.       end
  96.  
  97.       /* move the module into the specific directory */
  98.       if exists(directory||playername||'/'||filename) == '0' then do
  99.         say 'moving "'||filename||'" into the '||playername||' directory'
  100.         CALL rename(directory||filename,directory||playername||'/'||filename)
  101.       end
  102.       else do
  103.         say 'module "'||filename||'" is already in the "'||playername||'" directory'
  104.       end
  105.  
  106.     end
  107.  
  108.     eject
  109.  
  110.   end
  111.  
  112. end
  113.  
  114. /* restore quickstart state */
  115. quick quickstart
  116.  
  117. address 'REXX'
  118.  
  119. say 'all done'
  120.  
  121. /* remove the functions of the 'rexxsupport.library' */
  122. remlib('rexxsupport.library')
  123.  
  124. /* end of script */
  125. exit 0
  126.  
  127.  
  128.